<script setup lang="ts">

import {useRouter} from "vue-router";
import TeamCardList from "../components/TeamCardList.vue";
import {onMounted, ref} from "vue";
import myAxios from "../plugins/MyAxios.ts";


const router = useRouter()
const doJoinTeam = () => {
  router.push("/team/add")
}

const value  = ref('');
const teamList = ref([]);
const onSearch = ()=>{
  list(value.value)
}

onMounted(  ()=> {
 list()
})
const list = async (val='')=>{
  const teamListDate = await myAxios.get('team/list',{
    params:{
      searchText:val,
    }
      }
  )
  if (teamListDate) {
    teamList.value = teamListDate.data
  }

}



</script>
<template>
  <div class="team-page">
    <!-- 搜索和创建区域 -->
    <div class="search-create-container">
      <van-search 
        v-model="value"  
        @search="onSearch" 
        placeholder="请输入搜索关键词"
        class="team-search"
        shape="round"
        background="rgba(255, 255, 255, 0.9)"
      />
      <van-button 
        type="primary" 
        @click="doJoinTeam"
        class="create-team-btn"
        icon="plus"
      >
        创建队伍
      </van-button>
    </div>
    
    <!-- 队伍列表 -->
    <TeamCardList 
      :team-list="teamList"
      @refresh="list"
    />
  </div>
</template>
<style scoped>
.team-page {
  min-height: 100vh;
  background: transparent;
}

.search-create-container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  margin: 16px;
  padding: 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: fadeInUp 0.6s ease-out;
}

.team-search {
  margin-bottom: 16px;
}

.create-team-btn {
  width: 100%;
  height: 48px;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  transition: all 0.3s ease;
}

.create-team-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.create-team-btn:active {
  transform: translateY(0);
}

/* 深度选择器优化 Vant 组件样式 */
:deep(.van-search__content) {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  border: 1px solid rgba(102, 126, 234, 0.2);
}

:deep(.van-search__content:focus-within) {
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

:deep(.van-field__control) {
  color: #2c3e50;
  font-size: 14px;
}

:deep(.van-field__control::placeholder) {
  color: #bdc3c7;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .search-create-container {
    margin: 12px;
    padding: 12px;
  }
  
  .create-team-btn {
    height: 44px;
    font-size: 14px;
  }
}
</style>